Data Tables
Data tables are located inside packet table entries. A data table has one entry for each contiguous block of data to be inserted into the packet. Your server should concatenate the data from each block. Once all the blocks are inserted, the packet is complete.
Each data table entry is 16 bytes long. The first byte indicates the data source. There are currently four defined sources:
-
No Data-- No data should be inserted
-
Immediate Data -- The data follows as part of this data table entry
-
Sample Data -- The data resides in a track's sample
-
Sample Description -- The data resides in a track's sample description
The 15 bytes following the source-indicator byte contain either immediate data or the information needed to locate the data. The format of the information depends on the data source. All entries are padded to exactly 16 bytes.
The generic structure of a data table entry is shown below. The information format for each defined data source follows.
Table 6 Data table entry format
Field
|
Bytes
|
Description
|
Source
|
1
|
An 8-bit integer indicating the source of the data block. The following sources are defined:
0 -- No data
1 -- Immediate data
2 -- Sample data
3 -- Sample description data
|
Information
|
15
|
Either the immediate data or the necessary information to find the data, depending on the data source
|
No Data
If the source field is 0, there is no data. Ignore the following 15 bytes. Insert no data into the packet for this entry.
Field
|
Bytes
|
Description
|
Source
|
1
|
Always 0
|
Unused
|
15
|
Padding
|
Immediate Data
If the source field is 1, the data is in the information field of this entry. There is a 1-byte data length field, followed by up to 14 bytes of data.
Field
|
Bytes
|
Description
|
Source
|
1
|
Always 1
|
Length
|
1
|
8-bit value indicating the number of data bytes that follow
|
Data
|
14
|
The number of data bytes indicated by the length field, plus any padding to equal 14 bytes
|
Sample Data
If the source field is 2, the data is in a track's data sample. The track is either the media track being hinted or the hint track itself.
Field
|
Bytes
|
Description
|
Source
|
1
|
Always 2
|
Track ref index
|
1
|
8-bit integer indicating the track reference by index
|
Length
|
2
|
16-bit integer specifying the number of bytes to copy
|
Sample number
|
4
|
32-bit integer specifying the sample number to copy the data from
|
Offset
|
4
|
32-bit integer specifying the byte offset into the sample at which to begin copying data
|
Bytes per compression block
|
2
|
16-bit unsigned integer specifying the number of bytes in a compression block, after compression. A value of 0 is equivalent to a value of 1.
|
Samples per compression block
|
2
|
16-bit unsigned integer specifying the number of uncompressed samples in a compression block. A value of 0 is equivalent to a value of 1.
|
-
Source
-
An 8-bit integer, value 2, indicating the data source is sample data
-
Track ref index
-
An signed 8-bit integer used to determine which track's sample data should be used. A value of 0 indicates that the hint track refers to one media track. The reference is stored in the hint track's
'tref'
atom. Use that media track's sample data. A value of 1-127 indicates that the hint track refers to multiple media tracks. The references are stored in a table in the hint track's
'tref'
atom. The value of the track ref index field indicates which entry holds the track ID of the media track whose samples should be used. A value of -1 (FF hex) indicates that the data resides in a sample in the hint track itself.
-
Length
-
A 16-bit integer specifying the number of bytes to insert into the packet
-
Sample number
-
A 32-bit integer specifying the sample number. Use the sample table atom (
'stbl'
) in the indicated track to find the file specification and byte offset for this sample.
-
Offset
-
A 32-bit integer specifying where in the sample to begin copying the data from
-
Bytes per compression block
-
The number of bytes in a compression block, after compression. If this entry is 0 or 1, compression blocks are not used. See note below.
-
Samples per compression block
-
The number of uncompressed samples contained in a compression block. If this entry is 0 or 1, compression blocks are not used. See note below.
Normally, the byte offset for a sample is calculated by determining the sample number within a chunk, then adding the size of the preceding samples in that chunk to the chunk offset. If multiple samples are stored in compression blocks, as is the case with compressed audio, the sample size cannot be used to determine the offset within the chunk. Once you have determined the sample offset (the zero-based sample number within a chunk), the byte offset is determined using this formula:
SO = sample offset (0 if first sample, 1 if second sample, and so on)
CO = chunk offset
BCB = bytes per compression block
SPC = samples per compression block
byte offset = (SO * BCB / SPC) + CO
As an example, GSM audio typically compresses 160 samples into a 33-byte block, so a sample from a GSM audio track would have a BCB of 33 and an SPC of 160. The 161st sample in a chunk would have a sample offset of 160, so the byte offset of the sample would be (160 * 33 / 160) plus the chunk offset.
Sample Description Data
If the source field is 3, the data is in a sample description atom (
'stsd'
) either in the media track being hinted or in the hint track itself.
Field
|
Bytes
|
Description
|
Source
|
1
|
Always 3
|
Track ref index
|
1
|
8-bit integer indicating the track reference by index
|
Length
|
2
|
16-bit integer specifying the number of bytes to copy
|
Sample description index
|
4
|
32-bit integer specifying which entry in the sample description table to copy the data from
|
Offset
|
4
|
32-bit integer specifying the byte offset into the sample at which to begin copying data
|
Reserved
|
4
|
4 bytes that must be set to zero.
|
-
Source
-
An 8-bit integer, value 3, indicating the data source is a sample description.
-
Track ref index
-
An signed 8-bit integer used to determine which track's sample description should be used. A value of 0 indicates that the hint track refers to one media track. The reference is stoered in the hint track's
'tref'
atom. Use that media track's sample description. A value of 1-127 indicates that the hint track refers to multiple media tracks. The references are stored in a table in the hint track's
'tref'
atom. The value of the track ref index field indicates which entry in the
'tref'
atom holds the track ID of the media track whose sample description should be used. A value of -1 (FF hex) indicates that the data resides in the sample description of the hint track itself.
-
Length
-
A 16-bit integer specifying the number of bytes to insert into the packet
-
Sample description index
-
A 32-bit integer specifying the sample description by index. Sample descriptions are table entries in a sample description child atom (
'stsd'
) of a track's sample table atom (
'stbl'
). The sample description index corresponds to the table entry for a sample description.
-
Offset
-
A 32-bit integer specifying the byte in the sample description from which to begin copying data.
© 1998 Apple Computer, Inc.| Previous | Chapter Contents | Chapter Top | Next |